<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      align="right"
      layout="prev, pager, next"
      :current-page="currentPage"
      :page-size="pageSize"
      :total="totals"
      @current-change="gotoPage">
    </el-pagination>
  </div>
</template>

<script>
// import axios from 'axios'
export default {
  name: 'myTable',
  data () {
    return {
      tableData: [],
      currentPage:1,
      pageSize:5,
      totals:100
    }
  },
  methods:{
    gotoPage(curr){
      console.log(curr)
      this.currentPage=curr
      this.findPage()
    },
    findPage(){
      let para = {"currentPage":this.currentPage,"pageSize":this.pageSize}
      //发送axios请求到后端获取数据
      this.$http.post("/user/list",para)
        .then(result=>{
          //成功后获取的参数
          this.tableData = result.data.data
          this.totals = result.data.totals
        }).catch(result=>{
        alert("网络不通...")
      })
    }
  },
  mounted() {//钩子函数
    this.findPage()
  }
}
</script>


